﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <style>
        ul  {
            display:flex;
        }
        li{
            list-style:none;
        }
    </style>
</head>
<body>
    <div>
        <ul>
          
            <li>0</li>
            <li> : </li>
            <li>0</li>
        </ul>
    </div>
    <script>
        var str = ``
        var ul = document.querySelector(`ul`);
        let s = 0;
        let m = 0;
        let count=0;
        let times;
        window.onkeydown = function () {
            count++;
            console.log(count);
            if (count % 2 == 0) {
                // 暂停操作,设置下一次点击内容是开始
                
                clearInterval(times);
                h = 0; m = 0; s = 0; mi = 0
                return;
            }
            times = setInterval(function () {
                ul.lastElementChild.innerHTML = s;
                s++;
               
                if (s > 59) {
                    s = -1;
                    m++;
                    ul.firstElementChild.innerHTML = m;
                }
            }, 1000);
            // 开始操作,设置下一次点击内容是暂停
            
        }
        console.log(s);
        
    </script>
</body>
</html>